package com.initialize.common.tool.util;


import com.initialize.common.tool.md5.MD5;

import java.util.Random;
import java.util.UUID;

/**
 * Created with IntelliJ IDEA.
 * User: jane
 * Date: 2019/12/27
 * Time: 1:12 下午
 * Description:
 */
public class RandomTool {

    /**
     * 创建不含-的UUID
     * @return
     */
    public static String createUuidNo_() {
        return UUID.randomUUID().toString().replace("-", "");
    }
    /**
     * 创建含-的UUID
     * @return
     */
    public static String createUuid() {
        return UUID.randomUUID().toString();
    }

    /**
     * 生成随机4位数字
     * @return
     */
    public static String getSJNum() {
        String str = "0123456789";
        StringBuilder sb = new StringBuilder(4);
        for (int i = 0; i < 4; i++) {
            char ch = str.charAt(new Random().nextInt(str.length()));
            sb.append(ch);
        }
        return sb.toString();
    }

    /**
     * 生成区块地址
     *
     * @param phone 用户的手机号
     * @return
     */
    public static String createBelok(String phone) {
        String s = MD5.md52(phone);
        StringBuilder stringBuffer = new StringBuilder();
        stringBuffer.append("0x").append(s);
        String s1 = MD5.md52(s);
        stringBuffer.append(s1, 0, 8);
        return stringBuffer.toString();
    }



}